Reusing actions

You may want multiple buttons or frames to use the same action. Rather than copy and paste all the statements between the buttons and frames, assign the action to a different frame and then use the Call statement to run that action.

Specify the frame to call by using any of the ways that identify frames for the Go To statement. (See Jumping to a frame or scene.) If the frame cannot be located due to a naming error or because it hasn't streamed to the local computer, Flash ignores the Call statement. (You can use the _framesloaded property to check whether a frame is available.)

After the specified frame's actions run, control returns to the action that issued the Call statement.

To create a library of actions, create a movie and assign each action to a separate frame in the Timeline. Label each frame with the script's name to make it easy to call.

Flash provides no special way to pass or return values when using the Call statement. In fact, when you use the Call statement, the context is switched to the move clip being called, including the known variables. To pass values into a another movie clip, pass them in Flash variables. Similarly, the targeted movie clip should store any return values in variables. Basically, separate Set Variable statements should be used in conjunction with the Call statement to pass or return values.

For example, this statement sets the variables in Database before running the action AddDatabaseRecord:

Set Variable: "/Database:Name" = "Franz Schubert"
Set Variable: "/Database:Occupation" = "Musician"
Call ("/Database:AddDatabaseRecord")
If (/Database:Result eq "OK") 
	Go to And Stop ("OK")
Else
	Go To And Stop ("Error")
End If